package com.qf.controller;

import com.qf.pojo.resp.BaseResp;
import com.qf.service.DishesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/dishes")
public class DishesController {

    @Autowired
    DishesService dishesService;

    @RequestMapping("/findAll")
    public BaseResp findAll(){
        return dishesService.findAll();
    }

    @RequestMapping("/searchLike")
    public BaseResp searchLike(@RequestBody Map map){
        return dishesService.searchLike(map.get("dName").toString());
    }

    @RequestMapping("/findByDtype")
    public BaseResp findByDtype(@RequestBody Map map){
        return dishesService.findByDtype(map.get("dType").toString());
    }

    @RequestMapping("/findByBid")
    public BaseResp findByBid(@RequestBody Map map){
        return dishesService.findByBid(Integer.valueOf(map.get("bid").toString()));
    }

    @RequestMapping("/findByTypeAndBid")
    public BaseResp findByTypeAndBid(@RequestBody Map map){
        return dishesService.findByTypeAndBid(map.get("type").toString(),Integer.valueOf(map.get("bid").toString()));
    }
}
